﻿using System;

namespace SmartContentModule.Helpers
{
    internal static class ExceptionHelper
    {
        public static void HandleWarning(string message)
        {
            SCMException exception = new SCMException();
            exception.Message = "SCMWarning : " + message;
            exception.ExceptionType = SCMExceptionTypes.Warning;
            CallExceptionHandlerDelegate(exception);
        }

        public static void HandleError(string message, Exception ex)
        {
            SCMException exception = new SCMException();
            exception.Message = "SCMError : " + message + ex.Message;
            exception.ExceptionType = SCMExceptionTypes.Error;
            exception.Exception = ex;
            CallExceptionHandlerDelegate(exception);
        }

        private static void CallExceptionHandlerDelegate(SCMException ex)
        {
            if (ContentModule.HandleSCMException != null)
                ContentModule.HandleSCMException(null, ex);
        }
    }
}
